package com.tibco.notepad.ui;

import com.tibco.notepad.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.RelativeLayout;

public class WelcomeActivity extends Activity {
	private RelativeLayout mRelativeLayout;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.start);
		init();
		setAnimation();

	}

	private void init() {
		mRelativeLayout = (RelativeLayout) findViewById(R.id.start_layout);
	}

	private void setAnimation() {
		Animation animation = AnimationUtils.loadAnimation(this,
				R.anim.welcome_anim);
		mRelativeLayout.setAnimation(animation);
		animation.setAnimationListener(new AnimationListener() {

			@Override
			public void onAnimationStart(Animation animation) {

			}

			@Override
			public void onAnimationRepeat(Animation animation) {

			}

			@Override
			public void onAnimationEnd(Animation animation) {
				redirectTo();
			}
		});
	}

	private void redirectTo() {
		Intent intent = new Intent(this, MainActivity.class);
		startActivity(intent);
		finish();
	}
}
